<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>等待处理</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/common.js"></script>
    <script src="../../js/customer.js"></script>
</head>
<body>
<section class="alerttext">
    <label class="alertname">收到订单，正在为您下单</label>
    <label class="alertinfo" style="display:none;">您选择收藏的司机将会优先通知</label>
</section>
<section class="loadingarea">
    <div class="loadingtext">
        <label class="timearea" id="waitTime"></label>
        <label class="driver_info">已收到<span class="red mr5 ml5">0</span>位司机接单</label>
    </div>
    <div class="spinner"><i></i></div>
</section>
<section class="bottomarea">
    <button class="btn bottomonebtn" onclick="cancel()">取消</button>
</section>
<input type="hidden" name="waybillId" id="waybillId" />
</body>
<script>
$(function (){
	 //token验证
		checkToken();
	}); 
$(function(){
	 var LocString = String(window.document.location.href); 
	var waybillId=GetArgsFromHref("waybillId");  
	$("#waybillId").val(waybillId);
	/* var url = _global.serverHost +"/consignerOrder/orderFeeEstimation.htm";
     var data = {
    		 'waybillId':waybillId
     };
     _callAjaxRequest(url, data, callBack);

     function callBack(data) {
    	
     } */
	 settime();
});



function cancel(){
	//首页
	//window.location.href="${pageContext.request.contextPath}/consignerRegisterAndLogin/loginSuccess.htm"
	window.location.href="../"+_global.custIndexUrl;
}
var countEnd = 60;
var eachQuery=10;
var timeCount=0;


function settime() {
		var waybillId=$("#waybillId").val();
	    var obj = $("#waitTime");
	    if (timeCount == countEnd) {
	    	alert("请稍后，订单将为您优先安排");
	    	//window.location.href="${pageContext.request.contextPath}/consignerOrderManger/orderList.htm?waybillId="+waybillId;
	    	window.location.href="../"+_global.orderListUrl+"?waybillId="+waybillId;
	        return;
	    } else {
	       timeCount++;
	       var showTime='';
	       var min=parseInt(timeCount/60);
	       var ss=timeCount%60;
	       if(min<10){
	    	   min="0"+min;
	       }
	       if(ss<10){
	    	   ss="0"+ss;
	       }
	       showTime=min+":"+ss;
	       
	        obj.html(showTime);
	    }
	    
	    //定时查询订单是否成交
	    if((timeCount%eachQuery)==0){
	    	var customerUuid=getCookie("customerUuid")
	    	 $.ajax({
	    	        type:'POST',
	    	        url: _global.serverHost+'/consignerOrder/selectWaybillInfo.htm',
	    	        data: {'waybillId':waybillId,'customerUuid':customerUuid},
	    	        contentType:"application/x-www-form-urlencoded;charset=UTF-8",
	    	        success: function (data) {
	    	        	
	    	        	if(data.outResult=='1'){
	    	        		if(data.waybill.status*1>10){
	    	        			alert("已经派单");
		    	        		//window.location.href="${pageContext.request.contextPath}/consignerOrderManger/orderList.htm?waybillId="+waybillId;
		    	        		window.location.href="../"+_global.orderListUrl+"?waybillId="+waybillId;
		    	        	}
	    	        	}
	    	        }
	    	    });
	    	
	    }
	    setTimeout(function () {
	            settime(obj)
	        }
	        , 1000)
	}

</script>
</html>